package endcourseproject;

public class TickClock extends Thread 
{
	private int _tick_in_milliseconds = 0;

	public TickClock(int tick_in_milliseconds)
	{
		_tick_in_milliseconds = tick_in_milliseconds;
		
		this.setDaemon(true);
		this.start();
	}
	
	private int _tickCount = 0;
	public synchronized int getTickCount()
	{
		return _tickCount;
	}

	public void run()
	{
		while(true)
		{
			
			try 
			{
				Thread.sleep(_tick_in_milliseconds);
			} 
			catch (InterruptedException e)
			{
			}
			
			synchronized (this) 
			{
				_tickCount++;
			}
			
		}
	}
}
